package leetcode.all;

import datastruct.tree.TreeNode;

public class Solution100 {

    /**
     * 判断两棵树是否相同，即节点值和结构相同
     * @param p
     * @param q
     * @return
     */
    public static boolean isSameTree(TreeNode p, TreeNode q) {
        if(p==null&&q==null) return true;
        if(p!=null&&q==null||p==null&&q!=null) return false;
        return p.val==q.val && isSameTree(p.left,q.left) && isSameTree(p.right,q.right);
    }
}
